#include <bits/stdc++.h>
#include <string>
using namespace std;

int main()
{
    int n, m, count = 0;
    cin >> n >> m;
    int grid[n][m] = {0};
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> grid[i][j];
        }
    }
    int rows[n] = {0}, cols[m] = {0};
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (grid[i][j] == 1)
            {
                rows[i]++;
                cols[j]++;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (grid[i][j] == 1 && (rows[i]>1 || cols[j]>1))
                count++;
        }
    }
    cout << count;

    return 0;
}